from flask_wtf.file import FileAllowed

from .baseform import BaseForm
from wtforms import StringField, IntegerField, FileField,DateTimeField
from wtforms.validators import InputRequired,Length


class PublicPostForm(BaseForm):
  title = StringField(validators=[Length(min=2,max=100,message='请输入正确长度的标题！')])
  content = StringField(validators=[Length(min=2,message="请输入正确长度的内容！")])
  board_id = IntegerField(validators=[InputRequired(message='请输入板块id！')])


# 修改
class PublicCommentForm(BaseForm):
  content = StringField(validators=[Length(min=2,max=200,message="请输入正确长度！")])
  create_time = StringField(validators=[Length(min=10,max=20,message="请输入正确长度")])
  place_found = StringField(validators=[Length(min=2,max=200,message="请输入正确长度")])
  #image_data = FileField(validators=[FileAllowed({'png','jpg','jpeg','gif'},'只允许上传png,jpg,jpeg,gif格式得图片')])

# 搜索框表单接受 变量要和表单的一致（在这个地方卡住了，没改成一样的）
# 表单里 name 属性为 search，而视图函数中尝试从表单对象的 search_text 属性获取数据，二者名称不匹配。
class PublicSearchForm(BaseForm):
  search = StringField(validators=[Length(min=0, max=200, message="请输入正确长度！")])